﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Xml.Serialization;
using XCode;
using XCode.Configuration;
using XCode.DataAccessLayer;

namespace BingZi.HY.Core
{
    /// <summary>商品信息</summary>
    [Serializable]
    [DataObject]
    [Description("商品信息")]
    [BindIndex("PK_app_Product", true, "ID")]
    [BindTable("app_Product", Description = "商品信息", ConnName = "Center")]
    public partial class app_Product<TEntity> : Iapp_Product
    {
        #region 属性
        private Int32 _ID = 0;
        /// <summary>商品编号</summary>
        [DisplayName("商品编号")]
        [Description("商品编号")]
        [DataObjectField(true, true, false, 10)]
        [BindColumn(1, "ID", "商品编号", null, "int", 10, 0, false)]
        public virtual Int32 ID
        {
            get { return _ID; }
            set { if (OnPropertyChanging("ID", value)) { _ID = value; OnPropertyChanged("ID"); } }
        }

        private Int32 _CategoryID = 0;
        /// <summary>分类编号</summary>
        [DisplayName("分类编号")]
        [Description("分类编号")]
        [DataObjectField(false, false, false, 10)]
        [BindColumn(2, "CategoryID", "分类编号", null, "int", 10, 0, false)]
        public virtual Int32 CategoryID
        {
            get { return _CategoryID; }
            set { if (OnPropertyChanging("CategoryID", value)) { _CategoryID = value; OnPropertyChanged("CategoryID"); } }
        }

        private Int32 _Area = 0;
        /// <summary>区域</summary>
        [DisplayName("区域")]
        [Description("区域")]
        [DataObjectField(false, false, false, 10)]
        [BindColumn(3, "Area", "区域", null, "int", 10, 0, false)]
        public virtual Int32 Area
        {
            get { return _Area; }
            set { if (OnPropertyChanging("Area", value)) { _Area = value; OnPropertyChanged("Area"); } }
        }

        private String _Title = String.Empty;
        /// <summary>标题</summary>
        [DisplayName("标题")]
        [Description("标题")]
        [DataObjectField(false, false, false, 512)]
        [BindColumn(4, "Title", "标题", null, "nvarchar(512)", 0, 0, true)]
        public virtual String Title
        {
            get { return _Title; }
            set { if (OnPropertyChanging("Title", value)) { _Title = value; OnPropertyChanged("Title"); } }
        }

        private String _Subtitle = String.Empty;
        /// <summary>副标题</summary>
        [DisplayName("副标题")]
        [Description("副标题")]
        [DataObjectField(false, false, false, 256)]
        [BindColumn(5, "Subtitle", "副标题", null, "nvarchar(256)", 0, 0, true)]
        public virtual String Subtitle
        {
            get { return _Subtitle; }
            set { if (OnPropertyChanging("Subtitle", value)) { _Subtitle = value; OnPropertyChanged("Subtitle"); } }
        }

        private String _Picture = String.Empty;
        /// <summary>商品图片</summary>
        [DisplayName("商品图片")]
        [Description("商品图片")]
        [DataObjectField(false, false, false, 256)]
        [BindColumn(6, "Picture", "商品图片", null, "nvarchar(256)", 0, 0, true)]
        public virtual String Picture
        {
            get { return _Picture; }
            set { if (OnPropertyChanging("Picture", value)) { _Picture = value; OnPropertyChanged("Picture"); } }
        }


        private String _ContentText = String.Empty;
        /// <summary>商品详情</summary>
        [DisplayName("商品详情")]
        [Description("商品详情")]
        [DataObjectField(false, false, true, 1073741823)]
        [BindColumn(7, "ContentText", "商品详情", null, "ntext", 0, 0, true)]
        public virtual String ContentText
        {
            get { return _ContentText; }
            set { if (OnPropertyChanging("ContentText", value)) { _ContentText = value; OnPropertyChanged("ContentText"); } }
        }

        private String _ContactUs = String.Empty;
        /// <summary>联系方式或地址</summary>
        [DisplayName("联系方式或地址")]
        [Description("联系方式或地址")]
        [DataObjectField(false, false, true, 1073741823)]
        [BindColumn(8, "ContactUs", "联系方式或地址", null, "ntext", 0, 0, true)]
        public virtual String ContactUs
        {
            get { return _ContactUs; }
            set { if (OnPropertyChanging("ContactUs", value)) { _ContactUs = value; OnPropertyChanged("ContactUs"); } }
        }

        private Double _PriceNow = 0;
        /// <summary>现在价格</summary>
        [DisplayName("现在价格")]
        [Description("现在价格")]
        [DataObjectField(false, false, false, 53)]
        [BindColumn(9, "PriceNow", "现在价格", null, "float", 53, 0, false)]
        public virtual Double PriceNow
        {
            get { return _PriceNow; }
            set { if (OnPropertyChanging("PriceNow", value)) { _PriceNow = value; OnPropertyChanged("PriceNow"); } }
        }

        private Double _PriceOriginal = 0;
        /// <summary>原价</summary>
        [DisplayName("原价")]
        [Description("原价")]
        [DataObjectField(false, false, false, 53)]
        [BindColumn(10, "PriceOriginal", "原价", null, "float", 53, 0, false)]
        public virtual Double PriceOriginal
        {
            get { return _PriceOriginal; }
            set { if (OnPropertyChanging("PriceOriginal", value)) { _PriceOriginal = value; OnPropertyChanged("PriceOriginal"); } }
        }

        private Int32 _MinNumber = 1;
        /// <summary>最小成团数量</summary>
        [DisplayName("最小成团数量")]
        [Description("最小成团数量")]
        [DataObjectField(false, false, false, 10)]
        [BindColumn(11, "MinNumber", "最小成团数量", null, "int", 10, 0, false)]
        public virtual Int32 MinNumber
        {
            get { return _MinNumber; }
            set { if (OnPropertyChanging("MinNumber", value)) { _MinNumber = value; OnPropertyChanged("MinNumber"); } }
        }

        private Int32 _InventoryNumber = 0;
        /// <summary>库存数量</summary>
        [DisplayName("库存数量")]
        [Description("库存数量")]
        [DataObjectField(false, false, false, 10)]
        [BindColumn(12, "InventoryNumber", "库存数量", null, "int", 10, 0, false)]
        public virtual Int32 InventoryNumber
        {
            get { return _InventoryNumber; }
            set { if (OnPropertyChanging("InventoryNumber", value)) { _InventoryNumber = value; OnPropertyChanged("InventoryNumber"); } }
        }

        private Int32 _SalesNumber = 0;
        /// <summary>销量</summary>
        [DisplayName("销量")]
        [Description("销量")]
        [DataObjectField(false, false, false, 10)]
        [BindColumn(13, "SalesNumber", "销量", null, "int", 10, 0, false)]
        public virtual Int32 SalesNumber
        {
            get { return _SalesNumber; }
            set { if (OnPropertyChanging("SalesNumber", value)) { _SalesNumber = value; OnPropertyChanged("SalesNumber"); } }
        }

        private DateTime _StartTime = DateTime.Now;
        /// <summary>开始时间</summary>
        [DisplayName("开始时间")]
        [Description("开始时间")]
        [DataObjectField(false, false, false, 3)]
        [BindColumn(14, "StartTime", "开始时间", null, "datetime", 3, 0, false)]
        public virtual DateTime StartTime
        {
            get { return _StartTime; }
            set { if (OnPropertyChanging("StartTime", value)) { _StartTime = value; OnPropertyChanged("StartTime"); } }
        }

        private DateTime _EndTime = DateTime.Now.AddDays(15);
        /// <summary>结束时间</summary>
        [DisplayName("结束时间")]
        [Description("结束时间")]
        [DataObjectField(false, false, false, 3)]
        [BindColumn(15, "EndTime", "结束时间", null, "datetime", 3, 0, false)]
        public virtual DateTime EndTime
        {
            get { return _EndTime; }
            set { if (OnPropertyChanging("EndTime", value)) { _EndTime = value; OnPropertyChanged("EndTime"); } }
        }

        private Int32 _IsTop = (Int32)EnumProductIsTop.False;
        /// <summary>是否置顶</summary>
        [DisplayName("是否置顶")]
        [Description("是否置顶")]
        [DataObjectField(false, false, false, 3)]
        [BindColumn(16, "IsTop", "是否置顶", null, "tinyint", 3, 0, false)]
        public virtual Int32 IsTop
        {
            get { return _IsTop; }
            set { if (OnPropertyChanging("IsTop", value)) { _IsTop = value; OnPropertyChanged("IsTop"); } }
        }

        private Int32 _Status = (Int32)EnumProductStatus.Deactivate;
        /// <summary>状态</summary>
        [DisplayName("状态")]
        [Description("状态")]
        [DataObjectField(false, false, false, 3)]
        [BindColumn(17, "Status", "状态", null, "tinyint", 3, 0, false)]
        public virtual Int32 Status
        {
            get { return _Status; }
            set { if (OnPropertyChanging("Status", value)) { _Status = value; OnPropertyChanged("Status"); } }
        }

        private DateTime _LastTime = DateTime.Now;
        /// <summary>最后更新时间</summary>
        [DisplayName("最后更新时间")]
        [Description("最后更新时间")]
        [DataObjectField(false, false, false, 3)]
        [BindColumn(18, "LastTime", "最后更新时间", null, "datetime", 3, 0, false)]
        public virtual DateTime LastTime
        {
            get { return _LastTime; }
            set { if (OnPropertyChanging("LastTime", value)) { _LastTime = value; OnPropertyChanged("LastTime"); } }
        }

        private Int32 _LastUser = 0;
        /// <summary>最后更新用户</summary>
        [DisplayName("最后更新用户")]
        [Description("最后更新用户")]
        [DataObjectField(false, false, false, 10)]
        [BindColumn(19, "LastUser", "最后更新用户", null, "int", 10, 0, false)]
        public virtual Int32 LastUser
        {
            get { return _LastUser; }
            set { if (OnPropertyChanging("LastUser", value)) { _LastUser = value; OnPropertyChanged("LastUser"); } }
        }

        private String _LastIP = String.Empty;
        /// <summary>最后更新IP</summary>
        [DisplayName("最后更新IP")]
        [Description("最后更新IP")]
        [DataObjectField(false, false, false, 50)]
        [BindColumn(20, "LastIP", "最后更新IP", null, "nvarchar(50)", 0, 0, true)]
        public virtual String LastIP
        {
            get { return _LastIP; }
            set { if (OnPropertyChanging("LastIP", value)) { _LastIP = value; OnPropertyChanged("LastIP"); } }
        }
		#endregion

        #region 获取/设置 字段值
        /// <summary>
        /// 获取/设置 字段值。
        /// 一个索引，基类使用反射实现。
        /// 派生实体类可重写该索引，以避免反射带来的性能损耗
        /// </summary>
        /// <param name="name">字段名</param>
        /// <returns></returns>
        public override Object this[String name]
        {
            get
            {
                switch (name)
                {
                    case "ID" : return _ID;
                    case "CategoryID" : return _CategoryID;
                    case "Area" : return _Area;
                    case "Title" : return _Title;
                    case "Subtitle" : return _Subtitle;
                    case "Picture": return _Picture;
                    case "ContentText" : return _ContentText;
                    case "ContactUs" : return _ContactUs;
                    case "PriceNow" : return _PriceNow;
                    case "PriceOriginal" : return _PriceOriginal;
                    case "MinNumber" : return _MinNumber;
                    case "InventoryNumber" : return _InventoryNumber;
                    case "SalesNumber" : return _SalesNumber;
                    case "StartTime" : return _StartTime;
                    case "EndTime" : return _EndTime;
                    case "IsTop" : return _IsTop;
                    case "Status" : return _Status;
                    case "LastTime" : return _LastTime;
                    case "LastUser" : return _LastUser;
                    case "LastIP" : return _LastIP;
                    default: return base[name];
                }
            }
            set
            {
                switch (name)
                {
                    case "ID" : _ID = Convert.ToInt32(value); break;
                    case "CategoryID" : _CategoryID = Convert.ToInt32(value); break;
                    case "Area" : _Area = Convert.ToInt32(value); break;
                    case "Title" : _Title = Convert.ToString(value); break;
                    case "Subtitle" : _Subtitle = Convert.ToString(value); break;
                    case "Picture": _Picture = Convert.ToString(value); break;
                    case "ContentText" : _ContentText = Convert.ToString(value); break;
                    case "ContactUs" : _ContactUs = Convert.ToString(value); break;
                    case "PriceNow" : _PriceNow = Convert.ToDouble(value); break;
                    case "PriceOriginal" : _PriceOriginal = Convert.ToDouble(value); break;
                    case "MinNumber" : _MinNumber = Convert.ToInt32(value); break;
                    case "InventoryNumber" : _InventoryNumber = Convert.ToInt32(value); break;
                    case "SalesNumber" : _SalesNumber = Convert.ToInt32(value); break;
                    case "StartTime" : _StartTime = Convert.ToDateTime(value); break;
                    case "EndTime" : _EndTime = Convert.ToDateTime(value); break;
                    case "IsTop": _IsTop = Convert.ToInt32(value); break;
                    case "Status" : _Status = Convert.ToInt32(value); break;
                    case "LastTime" : _LastTime = Convert.ToDateTime(value); break;
                    case "LastUser" : _LastUser = Convert.ToInt32(value); break;
                    case "LastIP" : _LastIP = Convert.ToString(value); break;
                    default: base[name] = value; break;
                }
            }
        }
        #endregion

        #region 字段名
        /// <summary>取得商品信息字段信息的快捷方式</summary>
        public class _
        {
            ///<summary>商品编号</summary>
            public static readonly FieldItem ID = FindByName("ID");

            ///<summary>分类编号</summary>
            public static readonly FieldItem CategoryID = FindByName("CategoryID");

            ///<summary>区域</summary>
            public static readonly FieldItem Area = FindByName("Area");

            ///<summary>标题</summary>
            public static readonly FieldItem Title = FindByName("Title");

            ///<summary>副标题</summary>
            public static readonly FieldItem Subtitle = FindByName("Subtitle");

            ///<summary>商品图片</summary>
            public static readonly FieldItem Picture = FindByName("Picture");

            ///<summary>商品详情</summary>
            public static readonly FieldItem ContentText = FindByName("ContentText");

            ///<summary>联系方式或地址</summary>
            public static readonly FieldItem ContactUs = FindByName("ContactUs");

            ///<summary>现在价格</summary>
            public static readonly FieldItem PriceNow = FindByName("PriceNow");

            ///<summary>原价</summary>
            public static readonly FieldItem PriceOriginal = FindByName("PriceOriginal");

            ///<summary>最小成团数量</summary>
            public static readonly FieldItem MinNumber = FindByName("MinNumber");

            ///<summary>库存数量</summary>
            public static readonly FieldItem InventoryNumber = FindByName("InventoryNumber");

            ///<summary>销量</summary>
            public static readonly FieldItem SalesNumber = FindByName("SalesNumber");

            ///<summary>开始时间</summary>
            public static readonly FieldItem StartTime = FindByName("StartTime");

            ///<summary>结束时间</summary>
            public static readonly FieldItem EndTime = FindByName("EndTime");

            ///<summary>是否置顶</summary>
            public static readonly FieldItem IsTop = FindByName("IsTop");

            ///<summary>状态</summary>
            public static readonly FieldItem Status = FindByName("Status");

            ///<summary>最后更新时间</summary>
            public static readonly FieldItem LastTime = FindByName("LastTime");

            ///<summary>最后更新用户</summary>
            public static readonly FieldItem LastUser = FindByName("LastUser");

            ///<summary>最后更新IP</summary>
            public static readonly FieldItem LastIP = FindByName("LastIP");

            static FieldItem FindByName(String name) { return Meta.Table.FindByName(name); }
        }
        #endregion
    }

    /// <summary>商品信息接口</summary>
    public partial interface Iapp_Product
    {
        #region 属性
        /// <summary>商品编号</summary>
        Int32 ID { get; set; }

        /// <summary>分类编号</summary>
        Int32 CategoryID { get; set; }

        /// <summary>区域</summary>
        Int32 Area { get; set; }

        /// <summary>标题</summary>
        String Title { get; set; }

        /// <summary>副标题</summary>
        String Subtitle { get; set; }


        /// <summary>商品图片</summary>
        String Picture { get; set; }

        /// <summary>商品详情</summary>
        String ContentText { get; set; }

        /// <summary>联系方式或地址</summary>
        String ContactUs { get; set; }

        /// <summary>现在价格</summary>
        Double PriceNow { get; set; }

        /// <summary>原价</summary>
        Double PriceOriginal { get; set; }

        /// <summary>最小成团数量</summary>
        Int32 MinNumber { get; set; }

        /// <summary>库存数量</summary>
        Int32 InventoryNumber { get; set; }

        /// <summary>销量</summary>
        Int32 SalesNumber { get; set; }

        /// <summary>开始时间</summary>
        DateTime StartTime { get; set; }

        /// <summary>结束时间</summary>
        DateTime EndTime { get; set; }

        /// <summary>是否置顶</summary>
        Int32 IsTop { get; set; }

        /// <summary>状态</summary>
        Int32 Status { get; set; }

        /// <summary>最后更新时间</summary>
        DateTime LastTime { get; set; }

        /// <summary>最后更新用户</summary>
        Int32 LastUser { get; set; }

        /// <summary>最后更新IP</summary>
        String LastIP { get; set; }
        #endregion

        #region 获取/设置 字段值
        /// <summary>
        /// 获取/设置 字段值。
        /// </summary>
        /// <param name="name">字段名</param>
        /// <returns></returns>
        Object this[String name] { get; set; }
        #endregion
    }
}